<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js流程控制</title>
</head>
<body>
  <div id="did" style="color:blue;font-size:20px;">
    hello world !
  </div>
  <div>
    您喜欢的水果是：<input type="text" id="myInput" value="Banana">
  </div>
<script>
  //if语句
  var hour = new Date().getHours();//获取当前的小时
  if(hour>9){
    var oDiv = document.getElementById("did");//获取页面上的元素
    oDiv.innerHTML = "现在是早上";//修改div上面的内容
  }

  //换行符号
  document.write("<br>");
  //switch
  //根据文本框中输入的水果来弹不同的提示框
  var text;
  var oInput = document.getElementById("myInput");
  var fruit = oInput.value;
  switch (fruit){
    case "苹果":
      text = "苹果好吃";
      break;
    case "香蕉":
      text = "香蕉好吃";
      break;
    default:
      text = "不认识";
      break;
  }
  alert(text);
  document.write("<br>");


  //for循环
  var text = "";
  for (var i = 0;i<5;i++){
      text +="这是第"+i+"次循环<br>"
  }
  document.write(text);
  document.write("<br>");


//while循环
  var  text = "";
  var i =10;
  while(i>5){
      text +="这是第"+i+"次循环<br>";
      i--;
  }
  document.write(text);
</script>
</body>
</html>